package michal.GUI;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import michal.turniej.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class ZawodnikGUI extends JFrame {
	Zawodnik zawodnik;
	private JPanel contentPane;
	private JTextField textImie;
	private JTextField textNazwisko;
	private JTextField textWiek;
	private JTextField textUmiejetnosc;
	private JTextField textKlub;
	private JTextField textDruzyna;

	/**
	 * Launch the application.
	 */
	
	/**
	 * Create the frame.
	 */
	public ZawodnikGUI(Zawodnik zawodnik) {
		this.zawodnik = zawodnik;
		setTitle("Zawodnik");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 620, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		setContentPane(contentPane);
		
		JPanel panel = new JPanel();
		contentPane.add(panel, BorderLayout.CENTER);
		panel.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(13dlu;default):grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(66dlu;default)"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(71dlu;default)"),},
			new RowSpec[] {
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,}));
		
		JLabel lblImie = new JLabel("Imie");
		panel.add(lblImie, "4, 4, right, default");
		contentPane.add(textImie);
		textImie = new JTextField();
		panel.add(textImie, "6, 4, 5, 1, fill, default");
		textImie.setColumns(10);
		
		JLabel lblNazwisko = new JLabel("Nazwisko");
		panel.add(lblNazwisko, "4, 6, right, default");
		
		textNazwisko = new JTextField();
		panel.add(textNazwisko, "6, 6, 5, 1, fill, default");
		textNazwisko.setColumns(10);
		
		JLabel lblWiek = new JLabel("Wiek");
		panel.add(lblWiek, "4, 8");
		
		textWiek = new JTextField();
		panel.add(textWiek, "6, 8, 5, 1, fill, default");
		textWiek.setColumns(10);
		
		JLabel lblUmiejetnosc = new JLabel("Umiejetnosc");
		panel.add(lblUmiejetnosc, "4, 10, right, default");
		
		textUmiejetnosc = new JTextField();
		textUmiejetnosc.setText("");
		panel.add(textUmiejetnosc, "6, 10, 5, 1, fill, default");
		textUmiejetnosc.setColumns(10);
		
		JLabel lblKlub = new JLabel("Klub");
		panel.add(lblKlub, "4, 12, right, default");
		
		textKlub = new JTextField();
		panel.add(textKlub, "6, 12, 5, 1, fill, default");
		textKlub.setColumns(10);
		
		JLabel lblDruzyna = new JLabel("Druzyna");
		panel.add(lblDruzyna, "4, 14, right, default");
		
		textDruzyna = new JTextField();
		panel.add(textDruzyna, "6, 14, 5, 1, fill, default");
		textDruzyna.setColumns(10);
		
		JButton btnZapisz = new JButton("Zapisz");
		btnZapisz.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		panel.add(btnZapisz, "8, 16");
		
		JButton btnZamknij = new JButton("Zamknij");
		btnZamknij.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent arg0) {
				if(arg0.getClickCount() == 1){
					dispose();
				}
			}
		});
		btnZamknij.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		panel.add(btnZamknij, "10, 16");
	}

}
